﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class SystemManage_SystemParamConfig_ProductPropertyConfig : System.Web.UI.Page
{
    private Model.SYSPARAM SysParam
    {
        get
        {
            Model.SYSPARAM sysParam = null;
            if (ViewState["SysParam"] != null)
            {
                sysParam = (Model.SYSPARAM)ViewState["SysParam"];
            }
            return sysParam;
        }
        set
        {
            ViewState["SysParam"] = value;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Check.CheckPermission("100100102");
        if (!IsPostBack)
        {
            this.SysParam = new BLL.SYSPARAM().GetModel("002");
            if (this.SysParam != null)
            {
                txtProperty1Name.Text = this.SysParam.SP_PARAM13;
                txtProperty2Name.Text = this.SysParam.SP_PARAM14;
                txtProperty3Name.Text = this.SysParam.SP_PARAM15;
                txtProperty4Name.Text = this.SysParam.SP_PARAM16;
                txtProperty5Name.Text = this.SysParam.SP_PARAM17;
                txtProperty6Name.Text = this.SysParam.SP_PARAM18;
            }

            this.SysParam = new BLL.SYSPARAM().GetModel("002");


            Model.SYSPARAM SysParam2 = new BLL.SYSPARAM().GetModel("012");
            if (SysParam2 != null)
            {
                txtProperty6Name0.Text = SysParam2.SP_PARAM13;
                txtProperty6Name1.Text = SysParam2.SP_PARAM14;
                txtProperty6Name2.Text = SysParam2.SP_PARAM15;
                txtProperty6Name3.Text = SysParam2.SP_PARAM16;
            }

        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!Check.CheckPermission("100100102", "00017"))
        {
            Share.Alert(this.Page, "无权操作"); return;
        }
        if (txtProperty1Name.Text.Trim().Contains("'"))
        {
            Response.Write("<script>alert('您输入的属性1内容中包含危险字符，请重新输入！');</script>");
            return;
        }
        if (txtProperty2Name.Text.Trim().Contains("'"))
        {
            Response.Write("<script>alert('您输入的属性2内容中包含危险字符，请重新输入！');</script>");
            return;
        }
        if (txtProperty3Name.Text.Trim().Contains("'"))
        {
            Response.Write("<script>alert('您输入的属性3内容中包含危险字符，请重新输入！');</script>");
            return;
        }
        if (txtProperty4Name.Text.Trim().Contains("'"))
        {
            Response.Write("<script>alert('您输入的属性4内容中包含危险字符，请重新输入！');</script>");
            return;
        }
        if (txtProperty5Name.Text.Trim().Contains("'"))
        {
            Response.Write("<script>alert('您输入的属性5内容中包含危险字符，请重新输入！');</script>");
            return;
        }
        if (txtProperty6Name.Text.Trim().Contains("'"))
        {
            Response.Write("<script>alert('您输入的属性6内容中包含危险字符，请重新输入！');</script>");
            return;
        }


        if (txtProperty6Name0.Text.Trim().Contains("'"))
        {
            Response.Write("<script>alert('您输入的属性7内容中包含危险字符，请重新输入！');</script>");
            return;
        }
        if (txtProperty6Name1.Text.Trim().Contains("'"))
        {
            Response.Write("<script>alert('您输入的属性8内容中包含危险字符，请重新输入！');</script>");
            return;
        }
        if (txtProperty6Name2.Text.Trim().Contains("'"))
        {
            Response.Write("<script>alert('您输入的属性9内容中包含危险字符，请重新输入！');</script>");
            return;
        }
        if (txtProperty6Name3.Text.Trim().Contains("'"))
        {
            Response.Write("<script>alert('您输入的属性10内容中包含危险字符，请重新输入！');</script>");
            return;
        }
        bool result = new BLL.SYSPARAM().UpdateProductPropertyConfig(txtProperty1Name.Text.Trim(), txtProperty2Name.Text.Trim(), txtProperty3Name.Text.Trim(), txtProperty4Name.Text.Trim(), txtProperty5Name.Text.Trim(), txtProperty6Name.Text.Trim(), "002");




        Model.SYSPARAM para = new BLL.SYSPARAM().GetModel("012");
        para.SP_PARAM13 = txtProperty6Name0.Text.Trim();
        para.SP_PARAM14 = txtProperty6Name1.Text.Trim();
        para.SP_PARAM15 = txtProperty6Name2.Text.Trim();
        para.SP_PARAM16 = txtProperty6Name3.Text.Trim();


        para.SP_PARAM9 = DateTime.Now;
        para.SP_PARAM10 = DateTime.Now;
        para.SP_PARAM11 = DateTime.Now;
        para.SP_PARAM12 = DateTime.Now;




     
        new BLL.SYSPARAM().Update(para);



        if (result)
        {
            Share.InsertLog("100100102", "00017");
            Response.Write("<script>alert('保存成功');</script>");
        }
        else
        {
            Response.Write("<script>alert('保存失败');</script>");
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("ProductPropertyConfig.aspx");
    }
}
